import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/lifeCircle/data/api/life_topic_list_api.dart';
import 'package:casdon/modules/lifeCircle/data/repository/life_repository.dart';

class LifeTopicDetailUsecase {
  final LifeRepository _repository;

  const LifeTopicDetailUsecase(this._repository);

  Future<LifeTopic> execute(String topicId) async {
    try {
      final ret = await _repository.getTopicDetail(topicId: topicId);
      if (ret == null) {
        throw Exception('LifeTopicDetailUsecase data is null');
      }
      return ret;
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e('LifeTopicDetailUsecase 失败', e.toString(), StackTrace.current);
      throw Exception('LifeTopicDetailUsecase 失败');
    }
  }
}
